<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery-3.6.0.js"></script>
  </head>
  <body>
    <input type="text" id="name" value="zhangsan" /> <br />
    <div id="p1"></div>
    <div id="p2"></div>
    <button>获得值val()</button>
    <button>设置值val("li4")</button>
    <button>text()</button>
    <button>html()</button>
  </body>
</html>
<script>
  $('button:eq(0)').click(function () {
    console.log('获得值:' + $('#name').val())
  })

  $('button:eq(1)').click(function () {
    $('#name').val('li4')
  })

  $('button:eq(2)').click(function () {
    $('#p1').text('<h1>hello...</h1>')
  })

  $('button:eq(3)').click(function () {
    $('#p2').html('<h1>hello...</h1>')
  })
</script>
